import PropTypes from 'prop-types';

function myValidate(props, propName, componentName) {
  if (Number.isInteger(props[propName]) && props[propName] >= 0 && props[propName] <= 100) {
    return null //成功
  } else {
    return new Error(`${componentName}的属性${propName}必须是整数且大于等于零小于等于一百`)
  }
}

function Comment({ img/*图片 */, title/*标题 */, text/*内容 */, http/*网址 */, author/*作者 */,icon/*小图标 */ } ) {
  return (
    <div className="wrap">
      <div>
        <img src="" />
      </div>
      <div>
        <h4></h4>
        <p></p>
        <span></span>
        <div>
          <span></span>
        </div>
      </div>
    </div>
  )
}

Comment.propTypes = {
  // isRequired 必填的
  message: PropTypes.string,
  author: PropTypes.string.isRequired,
  likes: PropTypes.number,
  topic: PropTypes.oneOf(['时尚', '影视', '闲聊']),
  lili: PropTypes.shape({
    name: PropTypes.string,
    age: PropTypes.number,
  }),
  hot: myValidate,
}
// <Comment topic='游戏' />
// class Comment extends React.Component{
//   static propTypes = {
//     ...
//   }
// }

export default Comment;